<!-- 空调策略配置 -->

<template>
    <div class="leftRightContent">
        <!-- 左边子系统，
        右边菜单 -->
        <div class="leftContent" style="width: 250px; padding: 10px">
            <el-input placeholder="输入关键字搜索" v-model="deviceName" class="input-with-select">
                <el-button slot="append" icon="el-icon-search" @click="searchDevice"></el-button>
            </el-input>
            <div class="ddManager">
                <buildTree
                    :checkStrictly="false"
                    :showCheck="true"
                    :key="buildKey"
                    :height="secondTableHeight"
                    @handleCurrentChange="handleCurrentChange"
                    @allData="loadBuild"
                    @onCheck="onCheck"
                    @load="loadData"
                    eqtype="KT"
                ></buildTree>
            </div>
        </div>
        <div
            class="rightContent"
            style="width: calc(100% - 260px); padding: 10px; display: flex; flex-direction: column; height: 100%; gap: 10px"
        >
            <div class="rightContentHref">
                <airConfig :treeNode="checkList"></airConfig>
            </div>
        </div>
    </div>
</template>

<script>
import customDialog from '@/components/customComponents/customDialog'
import SelectUser from '@/components/customComponents/managementCenter/SelectUser'
import buildTree from '@/components/customComponents/managementCenter/buildAllTree'
import customButton from '@/components/customComponents/customForm/customButton'
import formIndex from '@/components/customComponents/customForm/formIndex'
import tableIndex from '@/components/customComponents/customeTable/iviewTable/singleViewTableAsync'
import navigationBar from '@/components/customComponents/managementCenter/navigationBarCustomTitle'
import airConfig from './components/air/airConfig'
import airDevice from './components/air/airDevice'
export default {
    components: {
        navigationBar,
        customButton,
        tableIndex,
        customDialog,
        formIndex,
        SelectUser,
        buildTree,
        airConfig,
        airDevice
    },
    data() {
        return {
            deviceName: '',
            buildKey: 'test1',
            secondTableHeight: document.body.clientHeight - 190,
            // 弹窗是否显示
            dialogShow: false,
            // 弹窗标题 (新增修改不同)
            dialogTitle: '',
            checkList: []
        }
    },
    created() {},
    methods: {
        loadData(d) {
            const data = d ? JSON.parse(d) : []
            this.checkList = data
        },
        onCheck(list) {
            this.checkList = list
        },
        loadBuild() {
            setTimeout(() => {
                try {
                    // document
                    //     .getElementsByClassName('ddManager')[0]
                    //     .children[0].children[0].children[0].children[0].children[0].children[0].click()

                    document
                        .getElementsByClassName('ddManager')[0]
                        .children[0].children[0].children[0].children[0].children[0].children[1].click()
                } catch (error) {}
            }, 100)
        },
        searchDevice() {
            const deviceName = this.deviceName
            console.log(deviceName)
            // this.deviceitem.eq_name = deviceName
            // this.GetDateDivce(this.deviceitem.build_id, this.deviceitem.eq_type, this.deviceitem.eq_name, this.deviceitem.typeid, 1)
        },
        success(success) {
            if (success) {
                this.buildKey = `test${parseInt(Math.random() * 100000000)}`
            }
        },
        handleCurrentChange(d) {
            // const self = this
            // AjaxCommon(`/api/Build/GetBuildInfo?bd_guid=${d.id}`, 'get', null).then((res) => {
            //     self.buildInfo = res?.data?.Message?.[0] ?? {}
            // })
        },
        getHeight() {
            this.secondTableHeight = document.body.clientHeight - 190
        },
        dialogClose() {
            this.dialogShow = false
        }
    },
    mounted() {
        this.$nextTick(() => {
            this.getHeight()
        })

        /*窗口自适应，关键代码*/
        window.onresize = () => {
            this.getHeight()
        }
    }
}
</script>

<style scoped>
.rightContentHref {
    height: 100%;
}
</style>
